<?php

use yii\db\Migration;

/**
 * Class m190308_012645_voice
 */
class m190308_012645_voice extends Migration
{
    /**
     * {@inheritdoc}
     */
    public function safeUp()
    {
        $tableOptions = null;
        if ($this->db->driverName === 'mysql') {
            // http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
            $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
        }
        $this->createTable('{{%voice}}', [
            'id' => $this->primaryKey(),
            'phone' => $this->string()->notNull()->comment('发送号码'),
            'content' => $this->text()->notNull()->comment('发送内容'),
            'trunk_name' => $this->string(50)->notNull()->comment('中继线路'),
            'file' => $this->string()->notNull()->comment('转换成的语音文件'),
            'spd' => $this->tinyInteger(3)->notNull()->comment('语速'),
            'pit' => $this->tinyInteger(3)->notNull()->comment('音调'),
            'vol' => $this->tinyInteger(3)->notNull()->comment('音量'),
            'per' => $this->tinyInteger(3)->notNull()->comment('发音人:0为普通女声，1为普通男生，3为情感合成-度逍遥，4为情感合成-度丫丫，默认为普通女声'),
            'user_id' => $this->integer()->notNull()->comment('发送人ID'),
            'created_at' => $this->integer()->notNull(),
            'updated_at' => $this->integer()->notNull(),
        ],$tableOptions);
    }

    /**
     * {@inheritdoc}
     */
    public function safeDown()
    {
        $this->dropTable('{{%voice}}');
    }

    /*
    // Use up()/down() to run migration code without a transaction.
    public function up()
    {

    }

    public function down()
    {
        echo "m190308_012645_voice cannot be reverted.\n";

        return false;
    }
    */
}
